package com.example.JavaWebApi.controller.systemController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.JavaWebApi.core.apiinterceptors.annotation.Authorize;
import com.example.JavaWebApi.model.entity.systemEntity.Dictionary;
import com.example.JavaWebApi.service.systemService.IDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: adks.process-api
 * @description:
 * @author: 杨泽
 * @create: 2022-05-05 17:15
 */
@Authorize
@RestController
@RequestMapping("/api/dictionary")
@Api(tags ="字典表")
public class DictionaryController {
    @Autowired
    private IDictionaryService dictionaryService;
    @ApiOperation("根据父级id获取全部的节点")
    @GetMapping("GetListByParentId")
    public List<Dictionary> getListByParentId(int parentId){
        return dictionaryService.getListByParentId(parentId);
    }
    @ApiOperation("获取字典树")
    @GetMapping("GetTreeList")
    public List<Dictionary> getTreeList(){return dictionaryService.getTreeList();}
    @ApiOperation("获取懒加载字典")
    @GetMapping("GetLazyNode")
    public IPage<Dictionary> getLazyNode(Integer parentId, int page, int limit){return dictionaryService.getLazyNode(parentId,page,limit);}
    @ApiOperation("创建字典数据")
    @PostMapping("CreateNode")
    public boolean createNode(@RequestBody Dictionary entity){
        return dictionaryService.createNode(entity);
    }
    @ApiOperation("更新字典数据")
    @PostMapping("UpdateNode")
    public boolean updateNode(@RequestBody Dictionary entity){
        return dictionaryService.updateNode(entity);
    }
    @ApiOperation("删除一个字典节点")
    @GetMapping("DeleteNode")
    public Boolean deleteNode(int id){
        return dictionaryService.deleteNode(id);
    }
}